<?php get_header('page');?>
<body>
<div id="topbg"></div>
<div id="container">
	<div id="header">
    	<?php include TEMPLATEPATH.'/controllers/banner/controller-banner.php';?>
        <?php require_once TEMPLATEPATH.'/views/menu/view-menu.php';?>
    </div>
    
    <div id="mid">
    	<div id="box-content">
            <!-- begin breadcrumb -->
            <?php require_once TEMPLATEPATH.'/views/breadcrumb/view-breadcrumb.php';?>
            <!-- end #breadcrumb -->	
            <!-- Book Tour -->
            <div id="content" class="page-book-tour">
            	<div class="content-box-1">
            	<span class="top-tabs-2"></span>
            	<?php 
            		require_once TEMPLATEPATH.'/orders/process.php';
            		if(isset($_POST['payment_status']))
	                {
	                 	$payment_status = $_POST['payment_status'];
	                 	$item_number    = $_POST['item_number'];
	                 	$result = db_table_get_id_by("orders", $item_number);
	                 	if($result)
	                 	{
	                 		$paymentID = $result[0]->paymentID;
	                 		db_update_table_field_id($paymentID, "paymentStatus", $payment_status); 
	                 	}	
	                }            		
            	?>
            	
	                <form action="" method="post">                	
	                    <?php
	                    /*
	                    if(!isset($_GET['tour-ID']) || $_GET['tour-ID']=="" )
	            		{
	            			echo '<p style="padding:10px; color:red;">You are not choosen tour.Please Choosen tour and booking.</p>';
	            		}
	            		else 
	            		{*/
	                    
	            			$tour_ID = $_GET['tourID'];
	                     	$term ='';
	                     	$currentID = $tour_ID;	                     	        	
	 						if(wp_verify_nonce($_POST['act_submit_book_tour'],'act_submit_book_tour') && $_POST['next_step']=="next_step")
	 						{	 							
	 							if(isset($_POST['payment']) && $_POST['payment']=="Paypal")
	 							{
	 								require_once TEMPLATEPATH.'/views/tour/view-book-tour-process.php';
	 								if($orderID)
	 								{
		 								$item_name		= 'tour';
										$item_amount	= '3';
										$currency_code	= 'USD';
										
										require_once TEMPLATEPATH.'/views/tour/view-book-tour-process.php';
										$item_number	= $orderID;
										create_url_paypal($item_name,$item_amount,$currency_code,$item_number);
	 								}
	 								else {
	 									echo 'Error Paypal payment!';
	 								}	
		 						}
	 							else 
	 							{
	 								//print_r($_POST);
		 							require_once TEMPLATEPATH.'/orders/process.php';
		 							require_once TEMPLATEPATH.'/views/tour/view-book-tour-process.php';
		 							if($orderID)
		 							{		 								
		 								//require_once TEMPLATEPATH.'/views/tour/view-book-tour-thanks.php';
		 							}	 							
	 							}
	 						}
	 						else 
	 						{
		                        require_once TEMPLATEPATH.'/views/tour/view-book-tour-form.php';
		                    	require_once TEMPLATEPATH.'/views/book/view-payment-form.php';         
	 						}
	            		//}
	                    ?>
	                    <?php require_once TEMPLATEPATH.'/views/tour/view-similar-tours.php';?>
	                    <?php wp_nonce_field('act_submit_book_tour','act_submit_book_tour');?>
	                 </form>
              </div>
            </div> 
            <!-- End Book Tour -->
        </div>
        
        <?php get_sidebar();?>
    </div>
    
    <?php include TEMPLATEPATH.'/views/testimonial/view-home-testimonial.php';?>
    <?php get_footer('page');?>
